# print("hello python!!!")
# import urllib3
# # 创建poolManager实例
# http = urllib3.PoolManager()
# # 通过request方法创建请求，我们使用get方法
# rq = http.request('GET', 'https://www.baidu.com/?tn=92027909_hao_pg&H123Tmp=nunew11')
# # 查看服务器响应
# print('服务器响应码：', rq.status)
# # 查看响应实体
# print('响应实体：', rq.data)

# ------------------------------------------------------------------------------------

# 模拟浏览器添加请求头
import urllib3
url = 'https://www.baidu.com/?tn=92027909_hao_pg&H123Tmp=nunew11'
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36'}
rq = urllib3.PoolManager().request('GET', url, headers=headers)
# 查看服务器响应码
print('服务器的响应码：', rq.status)
# 查看响应实体
print('响应实体：', rq.data.decode('utf-8'))
